const path = require('path')

module.exports = {
  configureWebpack: {
    resolve: {
      alias: {
        '@': path.resolve(__dirname, 'src'),
        'static': path.resolve(__dirname, 'static')
      }
    }
  },
  chainWebpack: (config) => {
    // 发行或运行时启用了压缩时会生效
    config.optimization.minimizer('terser').tap((args) => {
      const compress = args[0].terserOptions.compress
      // 非 App 平台移除 console 代码(包含所有 console 方法，如 log,debug,info...)
      compress.drop_console = true
      compress.drop_debugger = true
      // 移除 console.warn 和 console.error 除外
      compress.pure_funcs = [
        'console.log'
      ]
      return args
    })
  }
}